package com.rongchuan.wt.mapper;

import com.rongchuan.wt.entity.Department;
import com.rongchuan.wt.entity.Employee;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DepartmentMapper {
    /**
     * 查询所有部门的名称
     * @return
     */
    @Select("SELECT name FROM department")
    List<String> list();

    /**
     *插入部门信息
     * @param department
     */
    @Insert("insert into department(name,code,create_time,update_time) " +
            "values" +
            "(#{name},#{code},#{createTime},#{updateTime})")
    void insert(Department department);

    /**
     * 条件查询
     * @param department
     * @return
     */
    List<Department> select(Department department);

    void update(Department department);


    int selectEmployeeList(Long id);

    @Delete("delete from department where id=#{id}")
    void delete(Long id);

    @Select("select id from department where name=#{depName}")
    Long selectByName(String depName);
}
